package cn.edu.abc.wangzi.adapter;
/*
 *  项目名：Wangzi
 *  包名：cn.edu.abc.wangzi.adapter
 *  创建者：SKFsky
 *  创建时间：2017/8/29 22:14
 *  描述:   美女适配器
 */


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.Interpolator;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import java.util.List;
import cn.edu.abc.wangzi.R;
import cn.edu.abc.wangzi.entity.GirlData;
import cn.edu.abc.wangzi.utils.PicassoUtils;

public class GridAdapter extends BaseAdapter{

    private Context mContext;
    //private List<GirlData> mList;
    private List<String> mList;
    //private GirlData data;
    private String data;
    private WindowManager wm;
    private int width;
    private int height;

    public GridAdapter(Context mContext, List<String> mList){
        this.mContext = mContext;
        this.mList = mList;
        wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        width = wm.getDefaultDisplay().getWidth();
        height = wm.getDefaultDisplay().getHeight();
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int i) {
        return mList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (convertView==null){
            viewHolder = new ViewHolder();
            convertView = View.inflate(mContext, R.layout.girl_item,null);
            viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageview);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        data = mList.get(position);
        //String url = data.getImgUrl();
        //PicassoUtils.loadImageViewSize(mContext,url,width/2,height/5,viewHolder.imageView);
        PicassoUtils.loadImageViewSize(mContext,data,width/2,height/5,viewHolder.imageView);
        //viewHolder.imageView.setImageResource(data);
        return convertView;
    }

    class ViewHolder{
        private ImageView imageView;
    }
}
